{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "\n",
    "cmap = \"Pastel1\"\n",
    "# cmap = \"gist_stern\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAADuCAYAAAD1Nd/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAxpJREFUeJzt3KGOHVQARdE9pAIBKEJIimn5BAQBR1JXVcm3ggKDpRhUHU2aENQkTAfow5y0JGPem2TyGrqWvuKInSuuuBeHwyF479wDeDsIgUoIjBCohMAIgUoIjBCohMDcO+3407fqGfLy8uG5J9zw/k8/nnvCGy+vnt97/OT+MUfdCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYE76Oufv73+7qx238sGjcy+46dXDL8894Y1/jv/pyI1AJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYE76TOv3Bx/e1Y5b+eTZZ+eecMPF4YdzT3jj8Gf17VFH3QhUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQHXiH0qffv7RXe24le9+uTr3hBu+evDo3BNeOxwOHfvrlRuBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKhO/EPp6R/Xd7XjVr558fO5J9z04twD/uPlVT1+ctRRNwKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBuTgcDkcfvry8PP7wO+rZ9a/nnvDaX6+un3/x8df3jznrRqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEqhP/UOL/y41AJQRGCFRCYIRAJQRGCFRCYIRAJQTmX8ENOfh0/NpwAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "arr = np.random.rand(6,3)\n",
    "plt.imshow(arr, extent=[0, 600, 0, 1200], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "# plt.ytickslabels()\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('weights.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAF0AAADuCAYAAABbLwsYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAmZJREFUeJzt3SFuQlEQQNFPU4FiA61hC7iuoRjWW4mpZw+soYSkjx0UvqA3gXP0iMnNmKfeYowx8b9e6gWekegB0QOiB0QPiB4QPSB6QPTA65zhr8PR8/UPp/Pvcbt5f7s259IDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9MCsf44+1qt77fEQbv3F2KUHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6IFZ/xwtv/f32uMxnH6m6XN3dcylB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOLMUa9w9Nx6QHRA6IHRA+IHhA9IHpA9IDoAdEDFzRjF2Cjx1eYAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y= np.random.rand(3,1)\n",
    "fig, ax = plt.subplots()\n",
    "plt.imshow(y, extent=[0, 200, 0, 600], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('y.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 220,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAF0AAADuCAYAAABbLwsYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAmRJREFUeJzt3bFNA0EQQNE7dKGvAsqgDCJX68S1ELqCC4xAWjqwdYH5CL8XTzD6mmSjnccYE7/rpV7gGYkeED0gekD0gOgB0QOiB0QPLHuGv88nz9dbPq+X5f34em/MpQdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDogXnPz7vbtvnn6IYxxmVdV/8c/UWiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0wLJn+HD4eNQe/8TXNE1vd6dcekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0gekD0gOgB0QOiB0QPiB4QPSB6QPSA6AHRA6IHRA+IHhA9IHpA9IDoAdEDogdED4geED0wjzHqHZ6OSw+IHhA9IHpA9IDoAdEDogdED4ge+AHHkxv5a78RqwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "b= np.random.rand(3,1)\n",
    "fig, ax = plt.subplots()\n",
    "plt.imshow(b, extent=[0, 200, 0, 600], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('b.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADkAAADuCAYAAACDI68SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAbNJREFUeJzt2jFKHVEUgOF5Ia11CsUijaWQHaR3xxZZQ3APQrC18PHIu1nCcwYmynf/rz7F+TnNwNzDGGPRffnoBf6HIhVFKopUFKn4umb48en5U30eHU/n54cfN9eX5qa4ZJGKIhVFKopUFKkoUlGkokhFkYoiFUUqilQUqShSUaSiSMUUkat+p//883uvPbY5vi3LcnNxbIpLFqkoUlGkokhFkYoiFUUqilQUqShSUaSiSEWRiiIVRSqKVBSpmCJy1cOIX9/u99pjk+PpvDy8Y26KSxapKFJRpKJIRZGKIhVFKopUFKkoUlGkokhFkYoiFUUqilQUqVj1ZuDufNhrj03+vnOfKS5ZpKJIRZGKIhVFKopUFKkoUlGkokhFkYoiFUUqilQUqShSUaRi1ZuB2/uXvfbY6LQsy/XFqSkuWaSiSEWRiiIVRSqKVBSpKFJRpKJIRZGKIhVFKopUFKkoUlGkYorIVQ8jXl+/77XHJmOM5erq8twUlyxSUaSiSEWRiiIVRSqKVBSpKFJRpKJIRZGKIhVFKopUFKkoUnEYY3z0Drub4pJFKopUFKkoUjFF5D+iyCK98ih9UwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x= np.random.rand(6,1)\n",
    "fig, ax = plt.subplots()\n",
    "plt.imshow(x, extent=[0, 200, 0, 1200], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('x.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 271,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAADuCAYAAAD1Nd/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAtVJREFUeJzt3CGOVGEQRtELGYHpFbCRMbOCUbNaDA7DSmYFI5qE5GG+gEDQnZB0B87RJf683JR4ot4dxxG8v/UDuA9CoBICIwQqITBCoBICIwQqITAP1wx///zprn5Dnh+fbv2Eu3Ycx+vpdPp4yayNQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUERghUQmCEQCUE5qrTOfzZh69fbv2EX76d6/nlolEbgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMA4pvWXnR+fbv2En47j6HThrI1AJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRX3lC6p/tAVR++frn1E35zb9/oUjYClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVDVu+M4Lh5+e3u7fPg/dVd3nb6dXx+eXz5eMmojUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEJirjml9//zpro5pnR+fbv2Eu3Ycx+vpdHJMi8sJgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIzFU3lPh32QhUQmCEQCUERghUQmCEQCUERghUQmB+AE69Ndk7UdRrAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "# arr = np.random.rand(6,3)\n",
    "\n",
    "mask = np.random.randint(2, size=(6,3))\n",
    "\n",
    "row = np.array([0, 1, 1, 2, 3, 4, 5])\n",
    "col = np.array([0, 0, 2, 0, 1, 2, 0])\n",
    "data = np.array([1, 1, 1, 1, 1, 1, 1])\n",
    "mask= csr_matrix((data, (row, col)), shape=(6, 3)).toarray()\n",
    "\n",
    "# plt.imshow(mask, extent=[0, 500, 0, 1000], cmap=\"binary\", alpha = 0.9)\n",
    "plt.imshow(1-mask, extent=[0, 500, 0, 1000], cmap=cmap, alpha = 0.9)\n",
    "\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('mask_sparse.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 270,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.6441893  0.         0.        ]\n",
      " [0.07065762 0.         0.77140383]\n",
      " [0.69323791 0.         0.        ]\n",
      " [0.         0.21766468 0.        ]\n",
      " [0.         0.         0.07984717]\n",
      " [0.9452726  0.         0.        ]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAADuCAYAAAD1Nd/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAu5JREFUeJzt3CGvnFUURuFVUoHo1FZUFYNFgq1F8X/rKkAS/gCKm5CgyAggDR/mTRFUzNykmUl5Hr3FFitHHLGfHMcRfHbrBbgPQqASAiMEKiEwQqASAiMEKiEwT68b/+muviHP5y9uvcJdO47j4XQ6vbxk1otAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQRGCFRCYIRAJQTmqtM579788rH2eJyv7+90zvnXH2+9wnt/v/ur05evL5r1IlAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRCYq45p/fbq9LH2eJRnt17gA569+OrWK7x3HMfFs14EKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqC68obSPd0Hqvr+599vvcJ/fPPq+a1XeBQvApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQ1ZPjOC4ePp/Plw//T33+w9tbr/CvP/94ePrtdy8vGfUiUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBghUAmBEQKVEBjHtD5hx3E8nE4nx7S4nBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMBcdUOJT5cXgUoIjBCohMAIgUoIjBCohMAIgUoIzD8Przes0Z5aXAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "d=mask*arr\n",
    "print d\n",
    "fig, ax = plt.subplots()\n",
    "d[d==0] = 1\n",
    "plt.imshow(d, extent=[0, 500, 0, 1000], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('sparse.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## patterned"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 0, 0],\n",
       "       [1, 0, 0],\n",
       "       [0, 1, 0],\n",
       "       [0, 1, 0],\n",
       "       [0, 0, 1],\n",
       "       [0, 0, 1]])"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from scipy.sparse import csr_matrix\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 269,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 0 0]\n",
      " [1 0 0]\n",
      " [0 1 0]\n",
      " [0 1 0]\n",
      " [0 0 1]\n",
      " [0 0 1]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "([], <a list of 0 Text yticklabel objects>)"
      ]
     },
     "execution_count": 269,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAADuCAYAAAD1Nd/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAtpJREFUeJzt1bFuXGUYRdHt4CJFojSQlH4Nu/BLUvBCacJbmBrJFUhu4KY5okkzA4zGoLXqrzi62rr/zXEcwZtrD+B1EAKVEBghUAmBEQKVEBghUAmBuT3n+PsPH467Tx8vteVsx7v3157wqj09Pf35/Pz83Sm3Z4Vw9+ljP//0499bdQEv94/XnvCqPTw8/HHqraeBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgjM7TnHx7v3vdw/XmrL2d5++XztCd94Td/nHP4IVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEAlBEYIVEJghEBVt9ce8E+83D9ee8I33n75fO0Jf3nz+2+n315wB/8hQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEqro5juP045ubX6tfLjeHf9ndcRw/nHJ4Vgj8f3kaqITACIFKCIwQqITACIFKCIwQqOorgEkom/WPZGoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "\n",
    "row = np.array([0, 1, 2, 3, 4, 5])\n",
    "col = np.array([0, 0, 1, 1, 2, 2])\n",
    "data = np.array([1, 1, 1, 1, 1, 1])\n",
    "pattern_mask= csr_matrix((data, (row, col)), shape=(6, 3)).toarray()\n",
    "\n",
    "print pattern_mask\n",
    "\n",
    "# plt.imshow(1-pattern_mask, extent=[0, 500, 0, 1000], cmap=\"binary\", alpha = 0.9)\n",
    "plt.imshow(1-pattern_mask, extent=[0, 500, 0, 1000], cmap=cmap, alpha = 0.9)\n",
    "\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "# ax.spines['top'].set_visible(False)\n",
    "# ax.spines['right'].set_visible(False)\n",
    "# ax.spines['bottom'].set_visible(False)\n",
    "# ax.spines['left'].set_visible(False)\n",
    "# plt.savefig('mask_pattern.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.6441893  0.         0.        ]\n",
      " [0.07065762 0.         0.        ]\n",
      " [0.         0.82089245 0.        ]\n",
      " [0.         0.21766468 0.        ]\n",
      " [0.         0.         0.07984717]\n",
      " [0.         0.         0.25828437]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAADuCAYAAAD1Nd/cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAAt9JREFUeJzt3CGOZVUUhtGvSIUQkrIg2jEBbCMYARjmC0Fg0MyBFugHqYZOX8wfEG1eVejcB6ylt9jiyxZHnLvjOIIPzl6A2yAEKiEwQqASAiMEKiEwQqASAnP/tPGfbuoZ8nL57OwVbtpxHK8eHh5eXDPrIlAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgREClRAYIVAJgXnS1zlvvv35fe3xPC99nfNPcRGohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIjBCohMAIgUoIzJM+03p8+eX72uNZPv7l97NXeMdvn3x49grP4iJQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERApUQGCFQCYERAtUT/1C6Nd/9+nj2Cu/4In8o8S8mBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMEKgEgIjBCohMHfHcVw9fLlcrh/+n/roxx/OXuFvrx9f3X/1zYtrRl0EKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAiMEKiEwQqASAnN/9gL/Nd9/+vnZK/zl9R9v+/rKWReBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKiEwAiBSgiMEKjq7jiOs3fgBrgIVEJghEAlBEYIVEJghEAlBEYIVEJg/gQdaCprBgZqWAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "d=pattern_mask*arr\n",
    "print d\n",
    "fig, ax = plt.subplots()\n",
    "d[d==0] = 1\n",
    "plt.imshow(d, extent=[0, 500, 0, 1000], cmap=cmap, alpha = 0.9)\n",
    "plt.xticks([],[])\n",
    "plt.yticks([],[])\n",
    "ax.spines['top'].set_visible(False)\n",
    "ax.spines['right'].set_visible(False)\n",
    "ax.spines['bottom'].set_visible(False)\n",
    "ax.spines['left'].set_visible(False)\n",
    "plt.savefig('pattern.png', dpi=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:min_env]",
   "language": "python",
   "name": "conda-env-min_env-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
